<template>
	<view class="mine-main">
		<view class="mine-top">
			<view class="mine-avatar" v-if="JSON.stringify(myInfo)!='{}'">
				<u-avatar :src="myInfo.headImgUrl" shape="circle" :size="60"></u-avatar>
				<view class="user-msg">
					<span class="users-name">{{myInfo.name}}</span>
					<span class="users-time">已经监测健康的第60天</span>
				</view>
			</view>
			<view class="mine-avatar wx-login" v-else @click="login_weixin">
				<u-avatar src="@/static/WeChatcopy.png" shape="circle" :size="60" ></u-avatar>
				<view class="user-msg">
					<span class="users-name">微信登录</span>
				</view>
			</view>
			<view class="users-icon">
					<u-icon name="kefu-ermai" color="#010300" size="28"></u-icon>
					<u-icon name="chat" color="#010300" size="28"></u-icon>
					<u-icon name="setting" color="#010300" size="28"></u-icon>
			</view>
		</view>
		<view class="logistics">
			<image class="logistics-left" src="@/static/icon/logistics1.png" mode=""></image>
			<span class="logistics-text">....</span>
			<view class="logistics-right">
				<image class="log-right" src="@/static/icon/logistics2.png" mode=""></image>
				<span>订单信息</span>
			</view>
		</view>
		<view class="activeName2">
			<span class="activeName-title">健康档案</span>
			<view class="active1">
				<view class="active1-top">
					<view class="active1-title">
						<image src="@/static/icon/docment3.png" mode="widthFix"></image>
						<span>基础数据</span>
					</view>
					<view class="active1-data">
                            <view class="data-list" v-for="(item,index) in tabsType" :key="index">
                            	 <span class="data-num">{{item.num}}</span>
								 <span class="data-units">{{item.units}}</span>
								 <span class="data-name">{{item.name}}</span>
                            </view>
					</view>
				</view>
				<view class="active1-more">
					<span>查看更多</span>
					<u-icon name="arrow-right-double" color="rgba(51,51,51,0.5)" size="14"></u-icon>
				</view>
			</view>
			<span class="activeName-title">诊疗档案</span>
			<view class="active1">
				<view class="active1-top active1-top-1">
					<view class="active1-title">
						<image src="@/static/icon/docment4.png" mode="widthFix"></image>
						<span>诊疗记录</span>
					</view>
					<view class="active1-msg">
						<image src="@/static/icon/peizhen8.png" mode="widthFix"></image>
						<view class="active1-right">
							<span class="text-1">四川大学华西医院（华西院区）</span>
							<span class="text-2">就诊时间：<span class="text-1">一</span></span>
							<span class="text-2">主治医师：<span class="text-1">一</span></span>
							<span class="text-2">就诊人员：<span class="text-1">一</span></span>
						</view>
					</view>
				</view>
				<view class="active1-more">
					<span>查看更多</span>
					<u-icon name="arrow-right-double" color="rgba(51,51,51,0.5)" size="14"></u-icon>
				</view>
			</view>
		</view>
		<tabbar :routePath="'/pages/mine/mine'" :typeBar="1" />
	</view>
</template>

<script>
	import {login} from "@/common/api/index.js"
	export default {
		data() {
			return {
				myInfo:{},
				tabsType: [{
						name: '血压',
						units:"mmHg",
						num:"一",
					},
					{
						name: '血糖',
						units:"mmol/L",
						num:"一",
					},
					{
						name: '体重',
						units:"kg",
						num:"一",
					},
					{
						name: '尿酸',
						units:"μmol/L",
						num:"一",
					},
				],
			}
		},
		onShow() {
			let users = uni.getStorageSync('doctorInfo')||null
			// console.log(users)
			if(users){
				this.myInfo =JSON.parse(users)
				this.getAsync()
			}else{
				this.myInfo ={}
				uni.$u.toast('点击微信登录')
			}
		},
		onLoad(res){
			 if(JSON.stringify(res)!='{}'&&!uni.getStorageSync('doctorInfo')){
				 //执行登录
				 // console.log(111)
				 this.loginTo(res)
			 }
			 // console.log(accountInfo.miniProgram.appId)
			 
		},
		methods: {
			   //微信登录
               login_weixin(){
				   // console.log(location)
				   //用于退出登录回来不会再调一次授权登录
				   const appID = 'wxe6dcb0b3f15e8292'; //公众号appID
				   const callBack = 'http://health.cpzsyun.com/pages/mine/mine'; //回调地址 就是你的完整地址登录页'http://health.cpzsyun.com/pages/mine/mine'
				   let links = 'health.cpzsyun.com';//域名'health.cpzsyun.com'
				   // //通过微信官方接口获取code之后，会重新刷新设置的回调地址【redirect_uri】
				   window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
				   appID + '&redirect_uri=' + encodeURIComponent(callBack) +
				   '&response_type=code&scope=snsapi_userinfo&state=' + encodeURIComponent(links) +         
				   '#wechat_redirect'
			   },
			   //获取用户信息
			   async loginTo(res){
				   // console.log(res.code)
				   let result = await login(res.code)
				   // console.log(result)
					this.myInfo=result.data
					uni.setStorageSync('token',result.data.token);
					uni.setStorageSync('doctorInfo',JSON.stringify(result.data));
			   },
			   //获取物流
			   getAsync(){
				   
			   },
			   //获取健康档案
			   //获取诊疗档案
		}
	}
</script>

<style lang="scss" scoped>
	.mine-main {
		padding: 0 30rpx;
		padding-bottom: 180rpx;
		padding-top: 60rpx;
		display: flex;
		flex-direction: column;
		gap: 30rpx;

		.mine-top {
			width: 100%;
			 .mine-avatar{
				 width: 100%;
				 justify-content: space-between;
				 align-items: center;
				 display: flex;
				 gap: 40rpx;
				.user-msg{
					flex: 1;
					overflow: hidden;
					display: flex;
					flex-direction: column;
					gap: 20rpx;
					
				    .users-name {
						font-size: 58rpx;
						font-weight: 600;
						color: #010300;
						line-height: 58rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
				    }
	
				   .users-time {
						font-size: 28rpx;
						font-weight: 400;
						color: rgba(51, 51, 51, 0.7);
						line-height: 28rpx;
				    }
				 }
			 }
			 .wx-login{
				 justify-content: left;
				 align-items: center;
				 gap: 20rpx;
				 .user-msg{
					.users-name {
						font-size: 40rpx;
						font-weight: 600;
						color: #010300;
					} 
				 }
				 
			 }
             .users-icon {
				width: 100%;
              	margin-top: 40rpx;
              	display: flex;
              	gap: 20rpx;
				// margin-left: 70%;
				justify-content: right;
				// background-color: red;
              }
			.avartar {
				width: 130rpx;
				height: 130rpx;
				border-radius: 50%;
			}
               

				
			
		}

		.logistics {
			width: 100%;
			height: 116rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(0, 0, 0, 0.02);
			border-radius: 12rpx;
			display: flex;
			align-items: center;
			padding: 20rpx;

			.logistics-left {
				width: 68rpx;
				height: 68rpx;
			}

			.logistics-text {
				flex: 1;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				padding: 0 10rpx;
				font-size: 26rpx;
				font-weight: 400;
				color: #575757;
				line-height: 26rpx;
			}

			.logistics-right {
				width: 170rpx;
				height: 100%;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: center;
				border-left: 1px solid #E8E8E8;
				font-size: 24rpx;
				font-weight: 400;
				color: #575757;
				line-height: 24rpx;

				.log-right {
					width: 50rpx;
					height: 50rpx;
				}
			}
		}

		.activeName2 {

			width: 100%;
			display: flex;
			flex-direction: column;
			gap: 30rpx;

			.activeName-title {
				font-size: 32rpx;
				font-weight: 500;
				color: #333333;
			}

			.active1 {
				box-shadow: 0rpx 0rpx 10rpx 4rpx rgba(0, 0, 0, 0.06);
				background: #FFFFFF;
				border-radius: 20rpx;
				padding: 30rpx;
				display: flex;
				flex-direction: column;
				gap: 20rpx;

				.active1-top {
					width: 100%;
					padding: 30rpx;
					display: flex;
					border-radius: 20rpx;
					overflow: hidden;
					flex-direction: column;
					gap: 20rpx;
					background-image: url('@/static/icon/docment1.png');
					background-size: 100% 100%;
					justify-content: space-between;

					.active1-title {
						width: 100%;
						display: flex;
						align-items: center;
						height: 58rpx;
						gap: 20rpx;
						color: #12927C;
						font-size: 28rpx;

						image {
							width: 58rpx;
							height: 58rpx;
						}
					}

					.active1-msg {
						width: 100%;
						display: flex;
						gap: 20rpx;
						height: 160rpx;

						image {
							width: 160rpx;
							height: 160rpx;
							border-radius: 20rpx;
							overflow: hidden;
						}

						.active1-right {
							flex: 1;
							display: flex;
							flex-direction: column;
							height: 100%;
							gap: 10rpx;

							// justify-content: space-between;
							.text-1 {
								font-size: 26rpx;
								font-weight: 500;
								color: #333333;
							}

							.text-2 {
								font-size: 24rpx;
								font-weight: 400;
								color: #545B60;
							}
						}
					}
				    .active1-data{
						display: flex;
						justify-content: space-around;
						.data-list{
							display: flex;
							flex-direction: column;
							align-items: center;
							gap: 20rpx;
							.data-num{
								font-size: 42rpx;
								font-weight: 500;
								color: #333333;
							}
							.data-units{
								font-size: 24rpx;
								font-weight: 500;
								color: #333333;
							}
							.data-name{
								font-size: 26rpx;
								font-weight: 400;
								color: #545B60;
							}
						}
					}
				}

				.active1-top-1 {
					background-image: url('@/static/icon/docment2.png');
					background-size: 100% 100%;

					.active1-title {
						color: #AC3E26;
					}
				}

				.active1-more {
					color: rgba(51, 51, 51, 0.5);
					font-size: 22rpx;
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: center;
					gap: 10rpx;
				}
			}


		}

	}
</style>